import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
 * 1342. 将数字变成 0 的操作次数
 */
public class AnyNumber2Zero {


    @Test
    public void test1() {
        Assertions.assertEquals(6, numberOfSteps(14));
    }

    @Test
    public void test2() {
        Assertions.assertEquals(4, numberOfSteps(8));
    }

    @Test
    public void test3() {
        Assertions.assertEquals(12, numberOfSteps(123));
    }


    public int numberOfSteps(int num) {

        int i = 0;
        for (; num > 0; i++) {

            if (num % 2 == 0) {
                num /= 2;
            } else {
                num -= 1;
            }
        }

        return i;
    }
}
